package com.stylefeng.guns.modular.hhtb.service.impl;

import com.baomidou.mybatisplus.plugins.Page;
import com.stylefeng.guns.modular.hhtb.model.LogHhtbc;
import com.stylefeng.guns.modular.hhtb.dao.LogHhtbcMapper;
import com.stylefeng.guns.modular.hhtb.model.LogHhtbcDTO;
import com.stylefeng.guns.modular.hhtb.service.ILogHhtbcService;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.stylefeng.guns.modular.hhtb.util.StringUtils;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;
import java.util.Date;
import java.util.List;

/**
 * <p>
 * 现金转换的HHTB流水表 服务实现类
 * </p>
 *
 * @author wudi
 * @since 2018-09-15
 */
@Service
public class LogHhtbcServiceImpl extends ServiceImpl<LogHhtbcMapper, LogHhtbc> implements ILogHhtbcService {
  @Autowired
  private LogHhtbcMapper  logHhtbcMapper;

    @Override
    public  LogHhtbc getLogHhtbc(Integer userId,Integer fromId,String orderNo,BigDecimal preHHTBC,
                                 BigDecimal hHTBC,   Integer  hHTBCType,String remark,Integer type){
        LogHhtbc logHhtbc=new LogHhtbc();
        logHhtbc.setUserId(userId);
        logHhtbc.setFromId(fromId);
//        String orderNo = StringUtils.getOrderIdByTime(firstcode);
        logHhtbc.setOrderNo(orderNo);
        logHhtbc.setPreHHTBC(preHHTBC);
        logHhtbc.setHhtbc(hHTBC);
        logHhtbc.setHhtbcType(hHTBCType);
        logHhtbc.setRemark(remark);
        logHhtbc.setType(type);
        logHhtbc.setDataFlag(1);
        logHhtbc.setCreateTime(new Date());
        return logHhtbc;
    }
@Override
    public List<LogHhtbcDTO> selectAll(@Param("page")Page<LogHhtbcDTO> page,
                                       @Param("logHhtbcDTO")LogHhtbcDTO logHhtbcDTO) {
        List<LogHhtbcDTO> list = logHhtbcMapper.selectAll(page,logHhtbcDTO);
        Integer total = logHhtbcMapper.selectAllCount(logHhtbcDTO);
        page.setTotal(total);
        return list;
    }
}
